package com.zx._09_架构.重构;

/**
 * @program: knowledge
 * @description:
 * @author: xue.zhang
 * @create: 2021-11-17 10:21
 */
public class 让类提供应该提供的方法 {
    // 这个case不敢苟同，基础数据类，只作为基础的数据存储，具体的行为应该由使用方定义

    class BadExample {

        public int someMethod(Data data) {
            int i = data.getI();
            int j = data.getJ();
            int k = data.getK();
            return i * j * k;
        }

        private class Data {

            private int i;
            private int j;
            private int k;

            public Data(int i, int j, int k) {
                super();
                this.i = i;
                this.j = j;
                this.k = k;
            }

            public int getI() {
                return i;
            }

            public int getJ() {
                return j;
            }

            public int getK() {
                return k;
            }
        }
    }

    /* ---------------------分割线---------------------- */

    class GoodExample {

        public int someMethod(Data data) {
            return data.getResult();
        }

        private class Data {

            private int i;
            private int j;
            private int k;

            public Data(int i, int j, int k) {
                super();
                this.i = i;
                this.j = j;
                this.k = k;
            }

            public int getI() {
                return i;
            }

            public int getJ() {
                return j;
            }

            public int getK() {
                return k;
            }

            public int getResult() {
                return i * j * k;
            }
        }
    }
}
